<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <div style="padding-top: 1rem;"></div>

      <!-- table -->
      <!-- 考核单审核批量驳回原因 -->
      <FormPanel ref="formPanel" :list="formList1" :cols="1" :formType="'add'" labelWidth="110" :isSubmitBtn="false"  @formChange="formChangeHandle"/>

      <div style="padding-top: 1rem;"></div>
      <div
        :style="{
    position: 'absolute',
    left: 0,
    right: 0,
    zIndex: 9,
    borderTop: '1px solid #e9e9e9',
    padding: '10px 20px',
    background: '#fff',
    textAlign: 'right'
  }"
      >
        <multiuse-button type="primary" :click="saveDialog.bind()">确认</multiuse-button>
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
    </Spin>
  </div>

</template>
<script>
import { dictionary } from '@/utils/dictMixin';//字典的引入
//import { saveOne } from '@/api/claim/factory/guaranteeOil';
import { piLiangBuoHui } from '@/api/claim/factory/ClaimQueryFactory/index';

export default {
  props: ['boHuiIds'],
  mixins: [dictionary],
  components: {

  },
  data() {
    return {
      returnMsg:null,
      dataList1: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      visibleAdd:false,
      loading: false,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      formList1: this.createFormList1(),
      saveData: null,
      editData: {},

    };

  },
  async created() {
    // console.log(this.rowData.returnId,"this.rowData.returnId");
    //     await this.init(this.rowData.returnId);
  },
  methods: {
    // async init(val) {
    //   // console.log(this.rowData.returnId,"this.rowData.returnId");
    //  // let newVar = await selectById({id: val});
    //   this.editData = newVar.data;

    // },

    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //搜索获取数据
    changeHandle(val) {
      this.fetchParams = val;
      console.log(val);
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    // //保存
    // chooseModelName() {
    //   this.visibleDrawer = true;
    // },
    closeAdd() {
      this.visibleDrawer = false;
    },
    save(obj) {
      // this.formList1.find(x => x.fieldName == 'modelName').initialValue = obj[0].modelName;
      // this.formList1.find(x => x.fieldName == 'modelCode').initialValue = obj[0].modelCode;
      //this.modelName = obj[0].modelName;
      this.visibleDrawer = false;
    },
    saveAdd() {
      this.visibleDrawer = false;
      this.visibleAdd = false;
      this.fetchParams = { ...this.fetchParams };
    },
    //批量驳回保存 弹窗里点驳回按钮 调用批量驳回方法
    async saveDialog() {
      debugger;
      console.log(this.assessId,"assessId" );
      let str = '';
      this.boHuiIds.map(x => {
        str += x.claimId+ ',';
      });

      console.log(str);

      let returnMsg = this.formList1.find(item => item.fieldName == 'returnMsg').initialValue;
      this.saveData.claimId = str;
      this.saveData.checkRemarks = returnMsg;
      const res=await piLiangBuoHui(this.saveData);

      console.log(res);
      if(res.resultCode===200) {
        this.$emit('save');
        return this.$notify.success({title: '提示信息', message: '撤销成功'});
        this.fetchParams = {...this.fetchParams};

      }else{
        this.loading=false;
      }

    },
    //取消操作
    closeDialog(){
      this.$emit('close',{visible:false,data:this.selectedRows,type:'close'});
    },

    createFormList1(){
      return[
        {
          type:'TEXT_AREA',
          label:'撤销原因',
          fieldName:'returnMsg',
          placeholder:'请输入撤销原因...',
          rows:3,
          selfCols:1//元素占据几行
        }

      ];
    }
  }
};
</script>

<style lang="less"scoped></style>

